﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <title>在word当前光标处插入书签</title>
    <script type="text/javascript">
        function addBookMark() {
            var bkName = document.getElementById("txtBkName").value;
            var bkText = document.getElementById("txtBkText").value;
            pageofficectrl.word.AddDataRegion(bkName, bkText);
        }
        function delBookMark() {
            var bkName = document.getElementById("txtBkName").value;
            pageofficectrl.word.DeleteDataRegion(bkName);
        }

        function OnPageOfficeCtrlInit() {
            pageofficectrl.AddCustomToolButton("插入书签", "addBookMark()", 7);
            pageofficectrl.AddCustomToolButton("删除书签", "delBookMark()", 7);
        }
    </script>
</head>
<body>
   
    <form id="form1">
        <div style=" font-size:small; color:Red;">
            <asp:Label ID="Label4" runat="server" Text="关键代码：点右键，选择“查看源文件”，看js函数："></asp:Label>
            <asp:Label ID="Label5" runat="server" Text="function  addBookMark() 和 function delBookMark()"></asp:Label>
            <br />
            <asp:Label ID="Label3" runat="server" Text="插入书签时，请先输入要插入的书签名称和文本；删除书签时，请先输入相应的书签名称！"></asp:Label><br />
            <asp:Label ID="Label1" runat="server" Text="书签名称："></asp:Label><input id="txtBkName" type="text" value="test" />
            &nbsp;&nbsp;<asp:Label ID="Label2" runat="server" Text="书签文本："></asp:Label><input id="txtBkText" type="text" value="[测试]" />
        </div>
        <input id="Button1" type="button" onclick="addBookMark();" value="插入书签" />
        <input id="Button2" type="button" onclick="delBookMark()" value="删除书签" />
        <div style=" width:auto; height:800px;">
            @Html.Raw(ViewBag.poCtrl)
        </div>

    </form>
</body>
</html>
